package gui_classes;

import java_persistence.UserMapper;

import javax.swing.*;
import java.awt.*;


import domain.*;

/**
 * This panel represents user data
 * @author pratik661
 *
 */
public class UsersPagePanel extends JPanel {
	protected JLabel lblUserInformation;
		
	protected JLabel lblEditname;
	protected JLabel lblEditln;
	protected JLabel lblEdituname;
	protected JLabel lblEditpass;
	protected JLabel lblEditemail;
	protected JLabel lblEditphn;
	protected JLabel lblEditaddl;
	
//	private List<User> users = GUI_Main.getSession().getMapper(UserMapper.class).get_users();
//	private User user;
	
	
	/**
	 * Create the panel.
	 */
	public UsersPagePanel(User usr) {
		setLayout(null);
		
		
		setPreferredSize(new Dimension(600, 210));
		
		
		setAttr(usr);		
		
		
		JLabel lblFirstName = new JLabel("First Name:");
		lblFirstName.setBounds(12, 57, 88, 15);
		add(lblFirstName);
		

		
		JLabel lblLastName = new JLabel("Last Name:");
		lblLastName.setBounds(250, 58, 80, 15);
		add(lblLastName); 
		
		
		JLabel lblUsername = new JLabel("Username:");
		lblUsername.setBounds(12, 94, 88, 15);
		add(lblUsername);
		
		
		JLabel lblPassword = new JLabel("Password:");
		lblPassword.setBounds(250, 94, 80, 15);
		add(lblPassword);
		
		
		JLabel lblEmail = new JLabel("Email:");
		lblEmail.setBounds(12, 135, 70, 15);
		add(lblEmail);
		
		
		JLabel lblPhoneNumber = new JLabel("Phone Number:");
		lblPhoneNumber.setBounds(301, 135, 109, 15);
		add(lblPhoneNumber);
		
		JLabel lblAddressLn = new JLabel("Address:");
		lblAddressLn.setBounds(12, 178, 104, 15);
		add(lblAddressLn);

		
		
		
		lblUserInformation = new JLabel("User Information");
		lblUserInformation.setBounds(250, 25, 160, 15);
		add(lblUserInformation);

	}

	/**
	 * sets the attributes of the panel
	 * @param usr the user whose attributes you want displayed
	 */
	public void setAttr(User usr)
	{
		String fulName = usr.getName();
		String fname = fulName.split(" ")[0];
		String lname = fulName.split(" ")[1];
		
		lblEditname = new JLabel(fname); // edit and take from database
		lblEditname.setBounds(112, 57, 109, 15);
		add(lblEditname); 
		
		lblEditln = new JLabel(lname);
		lblEditln.setBounds(387, 57, 154, 15);
		add(lblEditln);
		
		lblEdituname = new JLabel(usr.getUsername());
		lblEdituname.setBounds(112, 94, 109, 15);
		add(lblEdituname);
		
		lblEditpass = new JLabel(usr.getPassword());
		lblEditpass.setBounds(387, 94, 172, 15);
		add(lblEditpass);
		
		lblEditemail = new JLabel(usr.getEmail());
		lblEditemail.setBounds(112, 135, 177, 15);
		add(lblEditemail);
		
		lblEditphn = new JLabel(usr.getPhone_number());
		lblEditphn.setBounds(422, 135, 154, 15);
		add(lblEditphn);
		
		lblEditaddl = new JLabel(usr.getAddress());
		lblEditaddl.setBounds(132, 178, 400, 15);
		add(lblEditaddl);
		
		
	}
}
